import com.example.yzc35326.User;
import org.junit.Test;
import sun.misc.Launcher;

import java.net.URL;

/**
 * @author 35326
 * @date 2021/2/27 21:12
 * 测试类的加载器
 */
public class ClassLoaderTest {
    public static void main(String[] args) {
        System.out.println("启动类加载器*************");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        for (URL urL : urLs) {
            System.out.println(urL);
        }


        System.out.println("扩展类加载器**************");
        String property = System.getProperty("java.ext.dirs");
        for (String s : property.split(";")) {
            System.out.println(s);
        }

    }


    @Test
    public void testArrayClassLoader(){
        String[] strings = new String[2];
        System.out.println(strings.getClass().getClassLoader());
        System.out.println(strings.getClass().getSuperclass());
        System.out.println(strings.getClass());
        User[] users = new User[2];
        Class<? extends User[]> aClass = users.getClass();
        System.out.println(aClass);
        System.out.println(aClass.getSuperclass());
        System.out.println(aClass.getClassLoader());

    }

}
